#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
//https://leetcode.cn/problems/self-dividing-numbers/submissions/487050793/

/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
bool Self_dividend(int n)
{
    int N = n;
    while (n)
    {
        int ret = n % 10;
        if (ret == 0)
            return false;
        if (N % ret != 0)
            return false;
        n = n / 10;
    }
    return true;
}

int* selfDividingNumbers(int left, int right, int* returnSize) {
    int* ans = (int*)malloc(sizeof(int) * (right - left + 1));
    int j = 0;
    for (int i = left; i <= right; i++)
    {
        if (Self_dividend(i))
        {
            ans[j] = i;
            j++;
        }
    }
    return ans;
}

int main()
{  
    int returnSize = 0;
    int *nums= selfDividingNumbers(21, 22, &returnSize);


	return 0;
}